package com.example.gezihua.myapplication;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.example.gezihua.myapplication.pull.IHeaderView;
import com.example.gezihua.myapplication.pull.IPullView;
import com.example.gezihua.myapplication.pull.PullToRefresh;

import java.util.List;

/**
 * Created by gezihua on 16-12-20.
 */

public class PullRefreshActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pull_refresh_layout);
        init();
    }

    private void init() {
        ((PullToRefresh)findViewById(R.id.pull)).setmRefreshView((IPullView) findViewById(R.id.pullto));
        ((PullToRefresh)findViewById(R.id.pull)).setHeaderView((IHeaderView)findViewById(R.id.header));
        ListView listView = (ListView) findViewById(R.id.pullto);
        listView.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return 60;
            }

            @Override
            public Object getItem(int position) {
                return null;
            }

            @Override
            public long getItemId(int position) {
                return 0;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                TextView view = new TextView(PullRefreshActivity.this);
                view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 100));
                view.setText(String.valueOf(position));
                return view;
            }
        });

    }
}
